import api from './instance'

// 热门榜
const hotList = () => {
  return api.get('/playlist/hot', {})
}

// 歌单播放列表
const playList = ({ order = 'hot', cat = '', limit = 50, offset = 0 }) => {
  return api.get(
    `/top/playlist?limit=${limit}&order=${order}&cat=${cat}&offset=${offset}`,
    {}
  )
}

// 推荐歌单
const personalized = (limit = 30) => {
  return api.get(`/personalized?limit=${limit}`, {})
}
// 精品歌单
const highquality = (limit = 20, before = 0) => {
  return api.get(
    `/top/playlist/highquality?limit=${limit}&before=${before}`,
    {}
  )
}

// 精品歌单标签
const highqualitytag = () => {
  return api.get('/playlist/highquality/tags', {})
}

// 歌单分类
const catlist = () => {
  return api.get('/playlist/catlist', {})
}

// 歌单详情
const playlistdetail = ({ id = '', s = 8 }) => {
  return api.get(`/playlist/detail?id=${id}&s=${s}`, {})
}

// 歌单收藏用户
const playlistSCollect = ({ id = '', limit = 20, offset = 0 }) => {
  return api.get(
    `/playlist/subscribers?id=${id}&limit=${limit}&offset=${offset}`,
    {}
  )
}

// 相关歌单推荐
const playlistRelated = ({ id = '' }) => {
  return api.get(`/related/playlist?id=${id}`, {})
}

// 歌单评论
const playlistComment = ({ id = '', limit = 20, offset = 0, before = 0 }) => {
  return api.get(
    `/comment/playlist?id=${id}&limit=${limit}&offset=${offset}&before=${before}`,
    {}
  )
}

/*
   1：收藏歌单
   2: 取消歌单
 */
const subPlayList = ({ t = 1, id = '' }) => {
  return api.get(`/playlist/subscribe?t=${t}&id=${id}`, {})
}

// 获取用户歌单
const playlistUser = ({ uid = '', limit = 30, offset = 0 }) => {
  return api.get(
    `/user/playlist?uid=${uid}&limit=${limit}&offset=${offset}`,
    {}
  )
}

// 添加歌曲到歌单
const addPlayList = ({ op = 'add', pid = '', tracks = '' }) => {
  return api.get(`/playlist/tracks?op=${op}&pid=${pid}&tracks=${tracks}`, {})
}

// 歌单详情
const listDetail = ({ id = '', s = 8 }) => {
  return api.get(`/playlist/detail?id=${id}&s=${s}`, {})
}

// 分别导出
export {
  hotList,
  playList,
  personalized,
  highquality,
  highqualitytag,
  catlist,
  playlistdetail,
  playlistSCollect,
  playlistRelated,
  playlistComment,
  subPlayList,
  playlistUser,
  addPlayList,
  listDetail
}
